﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace XthTicketDesktop
{
    /// <summary>
    /// SessionPopup.xaml 的交互逻辑
    /// </summary>
    public partial class SessionPopup : Window
    {
        public List<string> ButtonNames { get; set; }
        public SessionPopup()
        {
            InitializeComponent();
            var buttonNames = new List<string> { "2月8日", "2月9日", "2月10日", "2月11日", "2月12日", "2月13日" };
            this.LoadButtons(buttonNames);
            
        }

        public void LoadButtons(List<string> buttonNames)
        {
            ButtonNames = buttonNames;
            ButtonStackPanel.Children.Clear();

            for (int i = 0; i < buttonNames.Count; i += 2)
            {
                var row = new StackPanel { Orientation = Orientation.Horizontal };

                if (i < buttonNames.Count)
                {
                    var button1 = new Button { Content = buttonNames[i], Width = 120, Height = 25, Margin = new Thickness(5) };
                    button1.Click += Button_Click;
                    row.Children.Add(button1);
                }

                if (i + 1 < buttonNames.Count)
                {
                    var button2 = new Button { Content = buttonNames[i + 1], Width = 120, Height = 25, Margin = new Thickness(5) };
                    button2.Click += Button_Click;
                    row.Children.Add(button2);
                }

                ButtonStackPanel.Children.Add(row);
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Handle button click event here
            var button = sender as Button;
            MessageBox.Show($"你点击了按钮: {button.Content}");
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            // Handle cancel button click event here
            this.Visibility = Visibility.Collapsed;
        }

        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            // Handle confirm button click event here
            // You can add logic to process the selected buttons if needed
            MessageBox.Show("确认按钮被点击");
            this.Visibility = Visibility.Collapsed;
        }

    }
}
